package com.ts.api.module.match.plan.internal.executor.model;

import com.ts.api.module.api.entity.ApiUserRequest;
import com.ts.api.module.match.plan.internal.qualification.model.PlanQualificationResult;
import com.ts.api.module.match.plan.model.AbstractPlanMatch;
import com.ts.api.module.product.entity.po.ProductPlanPO;
import lombok.Data;

/**
 *  计划执行提交任务
 *
 *  @author Pan
 */
@Data
public class PlanExecuteTask {

    /** 本次请求id */
    private String reqId;
    /** 渠道计划匹配实体 */
    private AbstractPlanMatch abstractPlanMatch;
    /** 原始API传输对象 */
    private ApiUserRequest sourceApiUserRequest;
    /** 需要分发计划 */
    private ProductPlanPO distributePlan;

    /**
     *  构建任务
     *
     *  @param  planQualificationResult      计划资质通过实体类
     *  @param  distributePlan               分发计划
     *  @return PlanExecuteTask
     */
    public static PlanExecuteTask of(PlanQualificationResult planQualificationResult, ProductPlanPO distributePlan) {
        PlanExecuteTask planExecuteTask = new PlanExecuteTask();
        planExecuteTask.setReqId(planQualificationResult.getReqId());
        planExecuteTask.setSourceApiUserRequest(planQualificationResult.getApiUserRequest());
        planExecuteTask.setAbstractPlanMatch(planQualificationResult.getAbstractPlanMatch());
        planExecuteTask.setDistributePlan(distributePlan);
        return planExecuteTask;
    }
}
